﻿using NetCasbin.Model;
using NetCasbin.Persist;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Casbin.NET.Adapter.Dapper.Extensions
{
    public static class CasbinModelExtension
    {
        public static void LoadPolicyFromCasbinRules<TCasbinRule>
            (this Model casbinModel, IEnumerable<TCasbinRule> rules)
            where TCasbinRule : class, ICasbinRule
        {
            foreach (var rule in rules)
            {
                casbinModel.TryLoadPolicyLine(rule.ToList());
            }
        }
    }
}